﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using ExpressionEvaluator.Expceptions;

namespace ExpressionEvaluator.BuilderTreeNode
{
	/// <summary>
	/// Node which act as parent node of parent.
	/// </summary>
	internal abstract class OpaqueExpressionNode : BuilderTreeNodeBase
	{
		/// <summary>
		/// Gets the parent expression for expression.
		/// </summary>
		/// <param name="parent">The parent expression.</param>
		/// <param name="tree">The tree.</param>
		/// <returns>Expression for this node.</returns>
		public abstract Expression GetParentExpression(Expression parent, BuilderTree tree);

		/// <summary>
		/// Gets the parent expression for type.
		/// </summary>
		/// <param name="parent">The parent type.</param>
		/// <param name="tree">The tree.</param>
		/// <returns>Expression for this node.</returns>
		public abstract Expression GetParentExpression(Type parent, BuilderTree tree);

		/// <summary>
		/// Gets the expression.
		/// </summary>
		/// <param name="tree">The tree.</param>
		/// <returns>Expression value of this node.</returns>
		public override Expression GetExpression(BuilderTree tree)
		{
			throw new EvalException("Whoa, this node cannot be called as normal node, because it acts as parent node", Idents[0]);
		}

	}
}
